﻿// ----------------------------------------------------------------------------------
// Microsoft Developer & Platform Evangelism
// 
// Copyright (c) Microsoft Corporation. All rights reserved.
// 
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// ----------------------------------------------------------------------------------
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
// ----------------------------------------------------------------------------------

namespace Microsoft.Samples.CRUDSqlAzure.Phone.Models
{
    using System;
    using System.ComponentModel;
    using System.Data.Services.Common;

    [EntitySetAttribute("Reports")]
    [DataServiceKeyAttribute("ReportID")]
    public class Report : INotifyPropertyChanged
    {
        private int reportID;
        private string userID;
        private string description;
        private int? authorityID;
        private string mood;
        private byte[] photo;
        private string location;
        
       
        public event PropertyChangedEventHandler PropertyChanged;
        
        public int ReportID
        {
            get
            {
                return this.reportID;
            }

            set
            {
                this.reportID = value;
                this.OnPropertyChanged("ReportID");
            }
        }

        public string UserID
        {
            get
            {
                return this.userID;
            }

            set
            {
                this.userID = value;
                this.OnPropertyChanged("UserID");
            }
        }

        public string Description
        {
            get
            {
                return this.description;
            }

            set
            {
                this.description = value;
                this.OnPropertyChanged("Description");
            }
        }

        public int? AuthorityID
        {
            get
            {
                return this.authorityID;
            }

            set
            {
                this.authorityID = value;
                this.OnPropertyChanged("AuthorityID");
            }
        }

        public string Mood
        {
            get
            {
                return this.mood;
            }

            set
            {
                this.mood = value;
                this.OnPropertyChanged("Mood");
            }
        }

        public byte[] Photo
        {
            get
            {
                return this.photo;
            }

            set
            {
                this.photo = value;
                this.OnPropertyChanged("Photo");
            }
        }

        public string Location
        {
            get
            {
                return this.location;
            }

            set
            {
                this.location = value;
                this.OnPropertyChanged("Location");
            }
        }

        public static Report CreateReport(int reportID, int authorityID, string description, byte[] photo)
        {
            return new Report
            {                
                ReportID = reportID,
                AuthorityID = authorityID,
                Description = description,
                Photo = photo,
            };
        }

        protected virtual void OnPropertyChanged(string changedProperty)
        {
            var propertyChanged = this.PropertyChanged;
            if (propertyChanged != null)
            {
                propertyChanged(this, new PropertyChangedEventArgs(changedProperty));
            }
        }
    }
}
